$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL + 'bdbusiness/bbproject/list',
        datatype: "json",
        postData: {
            'entid': url('id')
        },
        colModel: [			
			{ label: 'id', name: 'id', index: 'id', width: 50, key: true ,hidden: true },
//			{ label: '', name: 'keynumber', index: 'keynumber', width: 80 }, 			
			{ label: '项目标题', name: 'name', index: 'name', width: 80 }, 			
//			{ label: '摘要', name: 'summary', index: 'summary', width: 80 }, 			
			{ label: '发布日期', name: 'pubdate', index: 'pubdate', width: 80 }, 			
//			{ label: '项目类型', name: 'type', index: 'type', width: 80 }, 			
			{ label: '投资方式', name: 'invest', index: 'invest', width: 80 }, 			
			{ label: '所属行业', name: 'industry', index: 'industry', width: 80 }, 			
//			{ label: '项目地点', name: 'area', index: 'area', width: 80 }, 			
//			{ label: '项目有效期', name: 'validity', index: 'validity', width: 80 }, 			
			{ label: '项目总金额（万元）', name: 'money', index: 'money', width: 80 }, 			
//			{ label: '拟吸引投资总金额', name: 'attractInvestmoney', index: 'attract_investmoney', width: 80 }, 			
//			{ label: '项目标注', name: 'label', index: 'label', width: 80 }, 			
//			{ label: '项目内容  <p>', name: 'content', index: 'content', width: 80 }, 			
//			{ label: '图片信息', name: 'img', index: 'img', width: 80 }, 			
//			{ label: '信息来源', name: 'source', index: 'source', width: 80 }, 			
//			{ label: '项目内容描述', name: 'describe', index: 'describe', width: 80 }, 			
//			{ label: '项目性质', name: 'nature', index: 'nature', width: 80 }, 			
//			{ label: '建设项目优势条件', name: 'advantage', index: 'advantage', width: 80 }, 			
//			{ label: '预计收入（以万元为单位）', name: 'annualincome', index: 'annualIncome', width: 80 }, 			
//			{ label: '预计投资回收期', name: 'paybackperiod', index: 'paybackPeriod', width: 80 }, 			
//			{ label: '预计就业人数', name: 'employment', index: 'employment', width: 80 }, 			
//			{ label: '项目环保简介', name: 'projectsynopsis', index: 'projectSynopsis', width: 80 }, 			
//			{ label: '投资者条件简介', name: 'investorsynopsis', index: 'investorSynopsis', width: 80 }, 			
//			{ label: '其他与项目相关信息', name: 'elsemsg', index: 'elseMsg', width: 80 }, 			
//			{ label: '项目单位', name: 'company', index: 'company', width: 80 }, 			
//			{ label: '注册地址', name: 'registeraddress', index: 'registerAddress', width: 80 }, 			
//			{ label: '运营地址', name: 'operationaddress', index: 'operationAddress', width: 80 }, 			
//			{ label: '法人', name: 'corporation', index: 'corporation', width: 80 }, 			
//			{ label: '法人联系方式', name: 'corporationcontactway', index: 'corporationContactWay', width: 80 }, 			
//			{ label: '项目联系人', name: 'contacts', index: 'contacts', width: 80 }, 			
//			{ label: '联系方式', name: 'contactway', index: 'contactWay', width: 80 }	
//			{
//                label: '操作', name: 'id', index: 'id', width: 80, 
//                formatter: function (value, options, row) {
//	                return '<a href="bbrecommendresult.html?id='+value+'">潜在招商企业</a>';
//                }
//            },
        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });

    vm.showGraph();
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		title: null,
		q:{
			name: '',
			industry: '',
			invest: '',
			money: '',
			entid: url('id'),
        },
		bBProject: {}
	},
	methods: {
		query: function () {
            $("#jqGrid").setGridParam({'page': 1});
			vm.reload();
		},
		details: function (event) {
			var id = getSelectedRow();
			if(id == null){
				return ;
			}
			vm.showList = false;
            vm.title = "详情";
            vm.getInfo(id)
		},
		showentname: function (event) {
            var id = getSelectedRow();
            if (id == null) {
                return;
            }
            window.location.href = 'bbrecommendresult.html?id=' + id;
        },
		getInfo: function(id){
			$.get(baseURL + "bdbusiness/bbproject/info/"+id, function(r){
                vm.bBProject = r.bBProject;
            });
		},
		showGraph: function(){
			var myChart = echarts.init(document.getElementById('showGraph'));
		    var option = {
		    	    title: {
		    	        text: '数据流'
		    	    },
		    	    tooltip: {},
		    	    animationDurationUpdate: 1500,
		    	    animationEasingUpdate: 'quinticInOut',
		    	    series : [
		    	        {
		    	            type: 'graph',
		    	            layout: 'none',
		    	            symbolSize: 50,
		    	            roam:false,
		    	            label: {
		    	                normal: {
		    	                    show: true
		    	                }
		    	            },
		    	            edgeSymbol: ['circle', 'arrow'],
		    	            edgeSymbolSize: [4, 10],
		    	            edgeLabel: {
		    	                normal: {
		    	                    textStyle: {
		    	                        fontSize: 20
		    	                    }
		    	                }
		    	            },
		    	            data: [{
		    	                name: 'Start',
		    	                x: 50,
		    	                y: 200
		    	            }, {
		    	                name: 'A',
		    	                x: 200,
		    	                y: 200
		    	            }, {
		    	                name: 'B',
		    	                x: 400,
		    	                y: 100
		    	            }, {
		    	                name: 'C',
		    	                x: 400,
		    	                y: 300
		    	            }, {
		    	                name: 'D',
		    	                x: 600,
		    	                y: 200
		    	            }, {
		    	                name: 'End',
		    	                x: 800,
		    	                y: 200
		    	            }],
		    	            links: [{
		    	                source: 'Start',
		    	                target: 'A'
		    	            },{
		    	                source: 'A',
		    	                target: 'B'
		    	            }, {
		    	                source: 'A',
		    	                target: 'C'
		    	            }, {
		    	                source: 'B',
		    	                target: 'D'
		    	            }, {
		    	                source: 'C',
		    	                target: 'D'
		    	            }, {
		    	                source: 'D',
		    	                target: 'End'
		    	            }],
		    	            lineStyle: {
		    	                normal: {
		    	                    opacity: 0.9,
		    	                    width: 2,
		    	                    curveness: 0
		    	                }
		    	            }
		    	        }
		    	    ]
		    	};

	        myChart.setOption(option);
		},
		reload: function (event) {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam',{ 
                postData: vm.q,
                page:page
            }).trigger("reloadGrid");
		}
	}
});